<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>strptime</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_009_177">&nbsp;</a>NAME</h4><blockquote>
strptime - date and time conversion
</blockquote><h4><a name = "tag_000_009_178">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="time.h.html">time.h</a>&gt;

char *strptime(const char *<i>buf</i>, const char *<i>format</i>, struct tm *<i>tm</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_009_179">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>strptime()</i>
function converts the character string pointed to by
<i>buf</i>
to values which are stored in the
<b>tm</b>
structure pointed to by
<i>tm</i>,
using the format specified by
<i>format</i>.
<p>
The
<i>format</i>
is composed of zero or more directives.
Each directive is composed of one of the following:
one or more white-space characters (as specified by
<i><a href="isspace.html">isspace()</a></i>;
an ordinary character (neither <i>%</i> nor a
white-space character);
or a conversion specification.
Each conversion specification is composed of a
<i>%</i>
character followed by a conversion character which
specifies the replacement required.
There must be white-space or other
non-alphanumeric characters between any two
conversion specifications.
The following conversion specifications are supported:
<dl compact>

<dt>%a<dd>is the day of week, using the locale's weekday names;
either the abbreviated or full name may be specified.

<dt>%A<dd>is the same as %a.

<dt>%b<dd>is the month, using the locale's month names;
either the abbreviated or full name may be specified.

<dt>%B<dd>is the same as %b.

<dt>%c<dd>is replaced by the locale's appropriate date and time representation.

<dt>%C<dd>is the century number [0,99]; leading zeros are permitted but not required.

<dt>%d<dd>is the day of month [1,31]; leading zeros are permitted but not required.

<dt>%D<dd>is the date as %m/%d/%y.

<dt>%e<dd>is the same as %d.

<dt>%h<dd>is the same as %b.

<dt>%H<dd>is the hour (24-hour clock) [0,23];
leading zeros are permitted but not required.

<dt>%I<dd>is the hour (12-hour clock) [1,12];
leading zeros are permitted but not required.

<dt>%j<dd>is the day number of the year [1,366];
leading zeros are permitted but not required.

<dt>%m<dd>is the month number [1,12]; leading zeros are permitted but not required.

<dt>%M<dd>is the minute [0-59]; leading zeros are permitted but not required.

<dt>%n<dd>is any white space.

<dt>%p<dd>is the locale's equivalent of a.m or p.m.

<dt>%r<dd>12-hour clock time using the AM/PM notation if t_fmt_ampm is not an empty string in the LC_TIME portion of the current locale; in the
POSIX locale, this will be equivalent to %I:%M:%S %p.

<dt>%R<dd>is the time as %H:%M.

<dt>%S<dd>is the seconds [0,61]; leading zeros are permitted but not required.

<dt>%t<dd>is any white space.

<dt>%T<dd>is the time as %H:%M:%S.

<dt>%U<dd>is the week number of the year (Sunday as the first day of
the week) as a decimal number [00,53];
leading zeros are permitted but not required.

<dt>%w<dd>is the weekday as a decimal number [0,6], with 0 representing Sunday;
leading zeros are permitted but not required.


<dt>%W<dd>is the the week number of the year (Monday as the first day of
the week) as a decimal number [00,53];
leading zeros are permitted but not required.

<dt>%x<dd>is the date, using the locale's date format.

<dt>%X<dd>is the time, using the locale's time format.


<dt>%y<dd>is the year within century.
When a century is not otherwise specified,
values in the range 69-99 refer to years in
the twentieth century (1969 to 1999 inclusive); values in the range
00-68 refer to years in the twenty-first century (2000 to 2068 inclusive).
Leading zeros are permitted but not required.

<dt>%Y<dd>is the year, including the century (for example, 1988).

<dt>%%<dd>is replaced by %.

</dl>
<h5><a name = "tag_000_009_179_001">&nbsp;</a>Modified Directives</h5>
Some directives can be modified by the E and O modifier characters to
indicate that an alternative format or specification should be used rather
than the one normally used by the unmodified directive.  If the alternative
format or specification does not exist in the current locale,
the behaviour will be as if the unmodified directive were used.
<dl compact>

<dt>%Ec<dd>is the locale's alternative appropriate date and
time representation.

<dt>%EC<dd>is the name of the base year (period) in the
locale's alternative representation.

<dt>%Ex<dd>is the locale's alternative date representation.

<dt>%EX<dd>is the locale's alternative time representation.

<dt>%Ey<dd>is the offset from %EC (year only) in the locale's
alternative representation.

<dt>%EY<dd>is the full alternative year representation.

<dt>%Od<dd>is the day of the month using the locale's alternative
numeric symbols; leading zeros are permitted but not required.

<dt>%Oe<dd>is the same as %Od.

<dt>%OH<dd>is the hour (24-hour clock) using the locale's
alternative numeric symbols.

<dt>%OI<dd>is the hour (12-hour clock) using the locale's
alternative numeric symbols.

<dt>%Om<dd>is the month using the locale's alternative numeric
symbols.

<dt>%OM<dd>is the minutes using the locale's alternative numeric
symbols.

<dt>%OS<dd>is the seconds using the locale's alternative numeric
symbols.

<dt>%OU<dd>is the week number of the year (Sunday as the first
day of the week) using the locale's alternative numeric symbols.

<dt>%Ow<dd>is the number of the weekday (Sunday=0) using
the  locale's alternative numeric symbols.

<dt>%OW<dd>is the week number of the year (Monday as the first
day of the week) using the locale's alternative numeric symbols.

<dt>%Oy<dd>is the year (offset from %C) using the locale's alternative
numeric symbols.

</dl>
<p>
A directive composed of white-space characters is
executed by scanning input
up to the first character that is not white-space
(which remains unscanned),
or until no more characters can be scanned.
<p>
A directive that is an ordinary character is executed
by scanning the next character from the buffer.
If the character scanned from the buffer differs from the one
comprising the
directive, the directive fails, and the differing and subsequent
characters remain unscanned.
<p>
A series of directives composed of %n, %t, white-space characters or any
combination is executed by scanning
up to the first character that is not white space (which remains unscanned),
or until no more characters can be scanned.
<p>
Any other conversion specification is executed by scanning characters until a
character matching the next directive is scanned, or until no more characters
can be scanned.  These characters, except the one matching the next
directive, are then compared to the locale values associated with the
conversion specifier.  If a match is found, values for the appropriate
<b>tm</b>
structure members are set to values corresponding to the locale information.
Case is ignored when matching items in
<i>buf</i>
such as month or weekday names.
If no match is found,
<i>strptime()</i>
fails and no more characters are scanned.
<br>
</blockquote><h4><a name = "tag_000_009_180">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>strptime()</i>
returns a pointer to the character following the last character parsed.
Otherwise, a null pointer is returned.
</blockquote><h4><a name = "tag_000_009_181">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_009_182">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_183">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
Several &quot;same as&quot; formats, and the special processing
of white-space characters are provided in order to ease the use
of identical
<i>format</i>
strings for
<i><a href="strftime.html">strftime()</a></i>
and
<i>strptime()</i>.
<p>
Applications should use %Y (4-digit years) in preference to %y
(2-digit years).
<p>
It is unspecified whether multiple calls to 
<i>strptime()</i> 
using the same 
<b>tm</b>
structure will update the current contents of the structure
or overwrite all contents of the structure. Portable applications
should make a single call to 
<i>strptime()</i>
with a format and all data
needed to completely specify the date and time being converted.
</blockquote><h4><a name = "tag_000_009_184">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
This function is expected to be mandatory in the next issue of this
specification.
</blockquote><h4><a name = "tag_000_009_185">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="scanf.html">scanf()</a></i>,
<i><a href="strftime.html">strftime()</a></i>,
<i><a href="time.html">time()</a></i>,
<i><a href="time.h.html">&lt;time.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
